package com.learning.dubbo.registry.nacos.consumer;

import com.learning.dubbo.registry.nacos.api.GreetingsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;

/**
 * ClassName: Consumer
 * Description: 消费客户端
 * Date: 2020/6/15 13:43 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Slf4j
public class Consumer {
    public static void main(String[] args) throws Exception {
        consumer();
    }

    private static void consumer() throws IOException, InterruptedException {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("consumer.xml");
        context.start();

        // 获取远程服务代理
        GreetingsService greetingsService = (GreetingsService) context.getBean("greetingsService");
        // 执行远程方法
        String result = greetingsService.sayHi("Dubbo");
        // 显示调用结果
        log.info("~~~~~~~  {} ~~~~~~~~~~", result);
        // 代理对象
        log.info(greetingsService.getClass().getName());

        // .......可以在这里打个断点........
        context.close();


    }
}
